home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / Sources / CAWindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-04  |  37.0 KB  |  1,474 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Program Name:    Stiletto                                                                    */
  4. /*                                                                                                */
  5. /*    File Name:        CAWindow.c                                                                    */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-07-05    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. *************************************************************************************************/
  22.  
  23. /******************************************** HEADERS *******************************************/
  24.  
  25. #include "Resources.h"
  26. #include "ToolUtils.h"
  27.  
  28. #ifndef __TELEPHONES__
  29. #include "Telephones.h"
  30. #endif
  31.  
  32. #include "CAHandlers.h"
  33. #include "CAWindow.h"
  34. #include "Constants.h"
  35. #include "DNHandlers.h"
  36. #include "DNWindow.h"
  37. #include "LogWindow.h"
  38. #include "TermWindow.h"
  39. #include "Utilities.h"
  40.  
  41. /****************************************** DEFINITIONS *****************************************/
  42.  
  43. enum {
  44.     kBlindTransfer    =    0,
  45.     kConsultTransfer=    1
  46. };
  47.  
  48. /****************************************** PROTOTYPES ******************************************/
  49.  
  50. void    AttachCAWindowControls (CAWindowPtr caWindow, TELCAHandle caHand);
  51.  
  52. Boolean    DoCAWindowMouseDown (const EventRecord *theEvent);
  53. void    DoCAWindowClick (WindowPtr theWindow, const EventRecord * theEvent);
  54. void    DoCAWindowActivate (WindowPtr theWindow, Boolean becomingActive);
  55. void    DoCAWindowUpdate (WindowPtr theWindow);
  56. void    DoCAWindowOSEvent (const EventRecord *theEvent);
  57. void     DoCAWindowSuspend (Boolean doClipConvert);
  58. void     DoCAWindowResume (Boolean doClipConvert);
  59.  
  60. void     HandleAnswer (CAWindowPtr caWindow);
  61. void     HandleDeflect (CAWindowPtr caWindow);
  62. void     HandleReject (CAWindowPtr caWindow);
  63. void     HandleDrop (CAWindowPtr caWindow);
  64. void     HandleConf (CAWindowPtr caWindow);
  65. void     HandleConfSplit (CAWindowPtr caWindow);
  66. void     HandleTransfer (CAWindowPtr caWindow);
  67. void     HandlePark (CAWindowPtr caWindow);
  68. void     HandleCallBack (CAWindowPtr caWindow);
  69. void     HandleDial (CAWindowPtr caWindow);
  70. void     HandleHold (CAWindowPtr caWindow, short * value);
  71.  
  72. void    HandleBlindTransfer (CAWindowPtr caWindow);
  73. void    HandleConsultTransfer (CAWindowPtr caWindow);
  74.  
  75. void    PrepareDeflectDLOGUserItems (DialogPtr theDialog);
  76. short    DisplayDeflectDialog (CAWindowPtr caWindow);
  77. void    PutDeflectAttribToDialog (DialogPtr theDialog, DeflectAttribHandle theDeflectAttrib);
  78. void    PutDialogSetupToDeflectAttrib (DialogPtr theDialog, DeflectAttribHandle theDeflectAttrib);
  79.  
  80. void    PrepareTransferDLOGUserItems (DialogPtr theDialog);
  81. short    DisplayTransferDialog (CAWindowPtr caWindow);
  82. void    PutTransferAttribToDialog (DialogPtr theDialog, TransferAttribHandle theTransferAttrib);
  83. void    PutDialogSetupToTransferAttrib (DialogPtr theDialog, TransferAttribHandle theTransferAttrib);
  84.  
  85. void    PrepareParkCallDLOGUserItems (DialogPtr theDialog);
  86. short    DisplayParkCallDialog (Str255 parkDN);
  87.  
  88. void    PrepareGetDigitsDLOGUserItems (DialogPtr theDialog);
  89. short    DisplayGetDigitsDialog (Str255 digits);
  90.  
  91. void    PrepareGetUserUserInfoDLOGUserItems (DialogPtr theDialog);
  92. short    GetUserUserInfo (Str255 userUserInfo);
  93.  
  94. void    PrepareGetReasonDLOGUserItems (DialogPtr theDialog);
  95. short    GetReason (short * number);
  96.  
  97. void    HandleTransferWithCA (CAWindowPtr caWindow);
  98. void    HandleConferenceWithCA (CAWindowPtr caWindow);
  99.  
  100. void    PrepareGetCAListDLOGUserItems (DialogPtr theDialog, CAWindowPtr caWindow);
  101. short    DisplayGetCAListDialog (TELCAHandle *caHand, CAWindowPtr caWindow);
  102. void    BuildCAListMenu (MenuHandle theMenu, CAWindowPtr caWindow);
  103.  
  104. /******************************************** GLOBALS *******************************************/
  105.  
  106. extern    LogWindowPtr    gLogWindow;
  107. extern    TelWindowPtr    gTelWindow;
  108.  
  109. extern    ModalFilterUPP    gStandardFilterUPP;
  110. extern    UserItemUPP        gDrawBoxUPP;
  111. extern    UserItemUPP        gDrawDefaultUPP;
  112.  
  113. /************************************************************************************************/
  114. /************************************************************************************************/
  115.  
  116.  
  117. #pragma segment CAWindow
  118. Boolean    IsHandledByCAWindowList (CAWindowPtr caWindowList, const EventRecord * theEvent)
  119. {
  120.     Boolean        wasHandled = false;
  121.     CAWindowPtr tCAWindow = caWindowList;
  122.     
  123.     while (tCAWindow && !(wasHandled = IsHandledByCAWindow (tCAWindow, theEvent))) {
  124.         tCAWindow = tCAWindow->next;
  125.     }
  126.     
  127.     return (wasHandled);
  128. }
  129.  
  130.  
  131. #pragma segment CAWindow
  132. Boolean    IsHandledByCAWindow (CAWindowPtr caWindow, const EventRecord * theEvent)
  133. {
  134.     WindowPtr    theWindow;
  135.     Boolean        wasHandled = false;
  136.     char        key;
  137.     
  138.     if (caWindow != nil) {
  139.         switch ( theEvent->what ) {
  140.             case mouseDown:
  141.                 (void) FindWindow(theEvent->where, &theWindow);
  142.                 if (theWindow == (WindowPtr) caWindow) {
  143.                     wasHandled = DoCAWindowMouseDown (theEvent);
  144.                 }
  145.                 break;
  146.                             
  147.             case activateEvt:
  148.                 if ((CAWindowPtr) theEvent->message == caWindow) {
  149.                     DoCAWindowActivate ((WindowPtr) caWindow, (theEvent->modifiers & activeFlag) != 0);
  150.                     wasHandled = true;
  151.                 }
  152.                 break;
  153.                 
  154.             case updateEvt:
  155.                 if ((CAWindowPtr) theEvent->message == caWindow) {
  156.                     DoCAWindowUpdate ((WindowPtr) caWindow);
  157.                     wasHandled = true;
  158.                 }
  159.                 break;
  160.                 
  161.             case osEvt:
  162.                 if ((CAWindowPtr) FrontWindow () == caWindow) {
  163.                     DoCAWindowOSEvent (theEvent);
  164.                     wasHandled = false;
  165.                 }
  166.                 break;
  167.                     
  168.             case keyDown:
  169.             case autoKey:
  170.                 if ((CAWindowPtr) FrontWindow() == caWindow) {
  171.                     key = theEvent->message & charCodeMask;
  172.                     if ( theEvent->modifiers & cmdKey )    {        // Command key is down
  173.                         wasHandled = false;
  174.                     } else {
  175.                         switch (key) {
  176.                             case 't' :
  177.                             case 'T' :
  178.                                 HandleTransferWithCA (caWindow);
  179.                                 wasHandled = true;
  180.                                 break;
  181.                             
  182.                             case 'c' :
  183.                             case 'C' :
  184.                                 HandleConferenceWithCA (caWindow);
  185.                                 wasHandled = true;
  186.                                 break;
  187.                             
  188.                             case 'f' :
  189.                             case 'F' :
  190.                                 DumpCAFlags (caWindow->fCAHandle);
  191.                                 break;
  192.                                 
  193.                             case 'i' :
  194.                             case 'I' :
  195.                                 DumpCAInfo (caWindow->fCAHandle);
  196.                                 break;
  197.                                 
  198.                             case 's' :
  199.                             case 'S' :
  200.                                 DumpCAState (caWindow->fCAHandle);
  201.                                 break;
  202.                                 
  203.                             case 'e' :
  204.                             case 'E' :
  205.                                 DumpCAEvents ((*caWindow->fCAHandle)->hTELDN);
  206.                                 break;
  207.                                 
  208.                             default :
  209.                                 wasHandled = false;
  210.                         }
  211.                     }
  212.                 }
  213.                 break;
  214.             
  215.             default :
  216.                 wasHandled = false;
  217.         }
  218.     }
  219.     
  220.     return (wasHandled);
  221. }
  222.  
  223.  
  224. #pragma segment CAWindow
  225. Boolean    DoCAWindowMouseDown (const EventRecord *theEvent)
  226. {
  227.     short        part;
  228.     WindowPtr    theWindow;
  229.     Boolean        wasHandled = false;
  230.     
  231.     part = FindWindow(theEvent->where, &theWindow);
  232.     switch ( part ) {            
  233.         case inContent:
  234.             if ( theWindow != FrontWindow() ) {
  235.                 SelectWindow(theWindow);
  236.             } else
  237.                 DoCAWindowClick (theWindow, theEvent);
  238.                 
  239.             wasHandled = true;
  240.             break;        
  241.         
  242.         default :
  243.             wasHandled = false;    
  244.     }
  245.     
  246.     return (wasHandled);
  247. }
  248.  
  249.  
  250. #pragma segment CAWindow
  251. void    DoCAWindowClick (WindowPtr theWindow, const EventRecord * theEvent)
  252. {
  253.     Point            mousePos;
  254.     WindowPtr        savedPort;
  255.     short            part, value;
  256.     ControlHandle    theControl;
  257.     
  258.     GetPort    (&savedPort);
  259.     SetPort (theWindow);
  260.     
  261.     mousePos = theEvent->where;
  262.     GlobalToLocal (&mousePos);
  263.  
  264.     part = FindControl (mousePos, theWindow, &theControl);
  265.     switch (part) {
  266.         case 0 :        // invisible or inactive control was clicked
  267.             break;
  268.         
  269.         case inThumb :
  270.             break;
  271.         
  272.         case inButton :
  273.             part = TrackControl (theControl, mousePos, nil);
  274.             if (part != 0) {
  275.                 switch (GetCRefCon (theControl)) {
  276.                     case rAnswerCNTL :
  277.                         HandleAnswer ((CAWindowPtr) theWindow);
  278.                         break;
  279.                     case rDeflectCNTL :
  280.                         HandleDeflect ((CAWindowPtr) theWindow);
  281.                         break;
  282.                     case rRejectCNTL :
  283.                         HandleReject ((CAWindowPtr) theWindow);
  284.                         break;
  285.                     case rDropCNTL :
  286.                         HandleDrop ((CAWindowPtr) theWindow);
  287.                         break;
  288.                     case rConfCNTL :
  289.                         HandleConferenceWithCA ((CAWindowPtr) theWindow);
  290.                         break;
  291.                     case rConfSplitCNTL :
  292.                         HandleConfSplit ((CAWindowPtr) theWindow);
  293.                         break;
  294.                     case rTransferCNTL :
  295.                         HandleTransferWithCA ((CAWindowPtr) theWindow);
  296.                         break;
  297.                     case rTransfer2CNTL :
  298.                         HandleBlindTransfer ((CAWindowPtr) theWindow);
  299.                         break;
  300.                     case rParkCNTL :
  301.                         HandlePark ((CAWindowPtr) theWindow);
  302.                         break;
  303.                     case rCallBackCNTL :
  304.                         HandleCallBack ((CAWindowPtr) theWindow);
  305.                         break;
  306.                     case rDialCNTL :
  307.                         HandleDial ((CAWindowPtr) theWindow);
  308.                         break;
  309.                 }
  310.             }
  311.             break;
  312.         
  313.         case inCheckBox:
  314.             part = TrackControl (theControl, mousePos, nil);
  315.             if (part != 0) {
  316.                 value = (GetCtlValue (theControl)) ? false : true;
  317.                 
  318.                 switch (GetCRefCon (theControl)) {
  319.                     case rHoldCNTL :
  320.                         HandleHold ((CAWindowPtr) theWindow, &value);
  321.                         break;
  322.                 }
  323.                 
  324. //                SetCtlValue (theControl, value);
  325.             }
  326.             break;
  327.     }
  328.     
  329.     SetPort (savedPort);
  330. }
  331.  
  332.  
  333. #pragma segment CAWindow
  334. void    DoCAWindowActivate (WindowPtr theWindow, Boolean becomingActive)
  335. {
  336.     WindowPtr        savedPort;
  337.     ControlHandle    theControl;
  338.     
  339.     GetPort (&savedPort);
  340.     SetPort (theWindow);
  341.     
  342.     theControl = ((WindowPeek) theWindow)->controlList;
  343.     while (theControl != nil) {
  344.         HiliteControl (theControl, (becomingActive)? 0 : 0xFF);
  345.         theControl = (*theControl)->nextControl;
  346.     }
  347.         
  348.     SetPort (savedPort);
  349. }
  350.  
  351.  
  352. #pragma segment CAWindow
  353. void    DoCAWindowUpdate (WindowPtr theWindow)
  354. {
  355.     WindowPtr        savedPort;
  356.  
  357.     BeginUpdate (theWindow);    
  358.     if ( ! EmptyRgn (theWindow->visRgn) )
  359.     {
  360.         GetPort (&savedPort);
  361.         SetPort (theWindow);
  362.         
  363. //        EraseRect(&theWindow->portRect);
  364.         UpdtControl (theWindow, theWindow->visRgn);
  365.         
  366.         SetPort (savedPort);
  367.     }
  368.     EndUpdate (theWindow);
  369. }
  370.  
  371.  
  372. #pragma segment CAWindow
  373. void    DoCAWindowOSEvent (const EventRecord *theEvent)
  374. {
  375.     Boolean doConvert;
  376.     unsigned char evType;
  377.  
  378.     evType = (unsigned char) (theEvent->message >> 24) & 0x00ff; // Get the high byte.
  379.     switch (evType) {                     // The high byte of message is the type of event.
  380.         case suspendResumeMessage :
  381.             doConvert = (theEvent->message & convertClipboardFlag) != 0;
  382.             
  383.             if ((theEvent->message & resumeFlag) == 0)
  384.               DoCAWindowSuspend (doConvert);
  385.               
  386.             else DoCAWindowResume (doConvert);
  387.             break;
  388.     }
  389. }
  390.  
  391.  
  392. #pragma segment CAWindow
  393. void     DoCAWindowSuspend (Boolean doClipConvert)
  394. {
  395. #pragma unused (doClipConvert)
  396.  
  397.     DoCAWindowActivate (FrontWindow(), false);
  398. }
  399.  
  400.  
  401. #pragma segment CAWindow
  402. void     DoCAWindowResume (Boolean doClipConvert)
  403. {
  404. #pragma unused (doClipConvert)
  405.  
  406.     InitCursor ();
  407.     DoCAWindowActivate (FrontWindow(), true);
  408. }
  409.  
  410.  
  411. #pragma segment CAWindow
  412. CAWindowPtr    CreateCAWindow (TELCAHandle caHand, char * title)
  413. {
  414.     CAWindowPtr    caWindow;
  415.     WindowPtr    savedPort;
  416.     Ptr            tPtr;
  417.      
  418.     tPtr = NewPtrClear (sizeof (CAWindowRec));
  419.     if (tPtr == nil) {
  420.         AlertUser ("\pNot enough memory to create ca window !", MemError ());
  421.         return (nil);
  422.     }
  423.     
  424.     if (HasColorQD())
  425.         caWindow = (CAWindowPtr) GetNewCWindow (rCAWIND, tPtr, (WindowPtr)(-1L));
  426.     else
  427.         caWindow = (CAWindowPtr) GetNewWindow (rCAWIND, tPtr, (WindowPtr)(-1L));
  428.     
  429.     if (caWindow == nil) {
  430.         AlertUser ("\pUnable to get a WIND resource for ca window!", ResError ());
  431.         DisposPtr (tPtr);
  432.         return (nil);
  433.     }
  434.     
  435.     caWindow->fDeflectAttrib = (DeflectAttribHandle) NewHandleClear (sizeof(DeflectAttrib));
  436.     if (caWindow->fDeflectAttrib == nil) {
  437.         AlertUser ("\pNot enough memory to create ca window !", MemError ());
  438.         DisposeWindow ((WindowPtr) caWindow);
  439.         return (nil);
  440.     }
  441.     
  442.     caWindow->fTransferAttrib = (TransferAttribHandle) NewHandleClear (sizeof(TransferAttrib));
  443.     if (caWindow->fTransferAttrib == nil) {
  444.         AlertUser ("\pNot enough memory to create ca window !", MemError ());
  445.         DisposeWindow ((WindowPtr) caWindow);
  446.         return (nil);
  447.     }
  448.         
  449.     /**
  450.      **        Set the window's characteristics.
  451.      **
  452.      **/
  453.      
  454.     GetPort (&savedPort);
  455.     SetPort ((WindowPtr) caWindow);
  456.     TextSize (9);
  457.     SetPort (savedPort);
  458.  
  459.     setwtitle ((WindowPtr) caWindow, title);
  460.  
  461.     AttachCAWindowControls (caWindow, caHand);
  462.  
  463.     caWindow->fCAHandle = caHand;
  464.     caWindow->fConfInitiated = false;
  465.     caWindow->fTransferInitiated = false;
  466.     
  467.     (*caHand)->userData = (long) caWindow;    // so we can find the corresponding cawindow if given a caHand
  468.  
  469.     ShowWindow ((WindowPtr) caWindow);
  470.                 
  471.     return (caWindow);
  472. }
  473.  
  474.  
  475. #pragma segment CAWindow
  476. void    DisposeCAWindow (CAWindowPtr caWindow)
  477. {
  478.     OSErr        errCode;
  479.     TELCAHandle    caHand = caWindow->fCAHandle;
  480.     
  481.     if (caWindow != nil) {
  482.     
  483.         if (caWindow->fDeflectAttrib)
  484.             DisposHandle ((Handle) caWindow->fDeflectAttrib);
  485.     
  486.         if (caWindow->fTransferAttrib)
  487.             DisposHandle ((Handle) caWindow->fTransferAttrib);
  488.         
  489.         if (caHand) {
  490.             if ((errCode = TELCADispose (caHand)) != noErr)
  491.                 PutCLine (gLogWindow, kErrorColor, "### TELCADispose failed : %d", errCode);
  492.         }
  493.         
  494.         DisposeWindow ((WindowPtr) caWindow);
  495.     }
  496. }
  497.  
  498.  
  499. #pragma segment CAWindow
  500. void    AttachCAWindowControls (CAWindowPtr caWindow, TELCAHandle caHand)
  501. {
  502.     OSErr            errCode;
  503.     WindowPtr        savedPort;
  504.     ControlHandle    theControl;
  505.     long            caFeatureFlags, caOtherFeatures;
  506.     
  507.     GetPort (&savedPort);
  508.     SetPort ((WindowPtr) caWindow);
  509.     
  510.     caWindow->fAnswer     = GetNewControl (rAnswerCNTL, (WindowPtr) caWindow);
  511.     caWindow->fDeflect     = GetNewControl (rDeflectCNTL, (WindowPtr) caWindow);
  512.     caWindow->fReject     = GetNewControl (rRejectCNTL, (WindowPtr) caWindow);
  513.     caWindow->fDrop     = GetNewControl (rDropCNTL, (WindowPtr) caWindow);
  514.     caWindow->fConf     = GetNewControl (rConfCNTL, (WindowPtr) caWindow);
  515.     caWindow->fConf2     = GetNewControl (rConfSplitCNTL, (WindowPtr) caWindow);
  516.     caWindow->fTransfer = GetNewControl (rTransferCNTL, (WindowPtr) caWindow);
  517.     caWindow->fTransfer2 = GetNewControl (rTransfer2CNTL, (WindowPtr) caWindow);
  518.     caWindow->fPark     = GetNewControl (rParkCNTL, (WindowPtr) caWindow);
  519.     caWindow->fCallBack = GetNewControl (rCallBackCNTL, (WindowPtr) caWindow);
  520.     caWindow->fDial     = GetNewControl (rDialCNTL, (WindowPtr) caWindow);
  521.     
  522.     caWindow->fHold = GetNewControl (rHoldCNTL, (WindowPtr) caWindow);
  523.     
  524.     if ((errCode = TELGetCAFlags (caHand, &caFeatureFlags, &caOtherFeatures)) != noErr)
  525.         ; // PutCLine (gLogWindow, kErrorColor, "### TELGetCAFlags fails : %d", errCode);
  526.     
  527.     SetCtlValue (caWindow->fHold, (caFeatureFlags & holdActive));
  528.     
  529.     theControl = ((WindowPeek) caWindow)->controlList;
  530.     while (theControl != nil) {
  531.         HiliteControl (theControl, 0xFF);
  532.         theControl = (*theControl)->nextControl;
  533.     }
  534.         
  535.     SetPort (savedPort);
  536. }
  537.  
  538.  
  539. #pragma segment CAWindow
  540. void     HandleAnswer (CAWindowPtr caWindow)
  541. {
  542.     OSErr                errCode;
  543.     TELCAHandle    caHand = caWindow->fCAHandle;
  544.     
  545.     if (caHand) {
  546.         if ((errCode = TELAnswerCall (caHand)) == noErr)
  547.             PutLine (gLogWindow, "TELAnswerCall (%08x)", caHand);
  548.         else 
  549.             PutCLine (gLogWindow, kErrorColor, "### TELAnswerCall fails : %d", errCode);
  550.     }
  551. }
  552.  
  553.  
  554. #pragma segment CAWindow
  555. void     HandleDeflect (CAWindowPtr caWindow)
  556. {
  557.     OSErr                errCode;
  558.     TELCAHandle    caHand = caWindow->fCAHandle;
  559.     DeflectAttribHandle    tDeflectAttrib = caWindow->fDeflectAttrib;
  560.     
  561.     if (caHand) {
  562.         if (DisplayDeflectDialog (caWindow) == ok) {
  563.             errCode = TELDeflectCall (caHand, 
  564.                         (*tDeflectAttrib)->destDN, 
  565.                         (*tDeflectAttrib)->destName, 
  566.                         (*tDeflectAttrib)->subAddr);
  567.             if (errCode == noErr)
  568.                 PutLine (gLogWindow, "TELDeflectCall (%08x)", caHand);
  569.             else
  570.                 PutCLine (gLogWindow, kErrorColor, "### TELDeflectCall fails : %d", errCode);
  571.         }
  572.     }
  573. }
  574.  
  575.  
  576. #pragma segment CAWindow
  577. void     HandleReject (CAWindowPtr caWindow)
  578. {
  579.     OSErr                errCode;
  580.     short                reason;
  581.     TELCAHandle    caHand = caWindow->fCAHandle;
  582.     
  583.     if (caHand) {
  584.         if (GetReason (&reason) == ok)
  585.         {
  586.             if ((errCode = TELRejectCall (caHand, reason)) == noErr)
  587.                 PutLine (gLogWindow, "TELRejectCall (%08x)", caHand);
  588.             else 
  589.                 PutCLine (gLogWindow, kErrorColor, "### TELRejectCall fails : %d", errCode);
  590.         }
  591.     }
  592. }
  593.  
  594.  
  595. #pragma segment CAWindow
  596. void     HandleDrop (CAWindowPtr caWindow)
  597. {
  598.     OSErr        errCode;
  599.     Str255        userUserInfo;
  600.     TELCAHandle    caHand = caWindow->fCAHandle;
  601.     TELHandle    termHand = (*caHand)->hTEL;
  602.     
  603.     if (caHand) {
  604.         if ((errCode = TELGetInfo (termHand)) == noErr) {
  605.             if ((*(**termHand).pTELTerm).featureFlags & hasUserUserInfo)
  606.                 GetUserUserInfo (userUserInfo);
  607.         } else
  608.             PutCLine (gLogWindow, kErrorColor, "### TELGetInfo fails : %d", errCode);
  609.         
  610.         if ((errCode = TELDrop (caHand, userUserInfo)) == noErr)
  611.             PutLine (gLogWindow, "TELDrop (%08x)", caHand);
  612.         else 
  613.             PutCLine (gLogWindow, kErrorColor, "### TELDrop fails : %d", errCode);
  614.     }
  615. }
  616.  
  617.  
  618. #pragma segment CAWindow
  619. void     HandleConf (CAWindowPtr caWindow1)
  620. {
  621.     OSErr        errCode = noErr;
  622.     TELCAHandle    caHand1 = caWindow1->fCAHandle, caHand2;
  623.     long        caFeatureFlags, caOtherFeatures;
  624.     CAWindowPtr    caWindow2;
  625.     
  626.     if (caHand1) {
  627.         if (caWindow1->fConfInitiated == false) {
  628.             if ((errCode = TELGetCAFlags (caHand1, &caFeatureFlags, &caOtherFeatures)) == noErr) {
  629.                 if ((caHand2 = SetUpACall ((DNWindowPtr) (*caHand1)->refCon)) != nil) {
  630.                     errCode = TELConferencePrep (caHand1, caHand2, (*caHand1)->conferenceLimit);                            
  631.                     if (errCode == noErr) {
  632.                         PutLine (gLogWindow, "TELConferencePrep (%08x,%08x), ConfLimit = %d", caHand1, caHand2, (*caHand1)->conferenceLimit);
  633.  
  634.                         caWindow2 = (CAWindowPtr) (*caHand2)->userData;
  635.                         caWindow2->fConfInitiated = true;
  636.                         SetCTitle (caWindow2->fConf, "\pConf Est");
  637.                         
  638. //                            errCode = TELCAMsgHand ((*caHand2)->hTELDN, telAllCAMsgs, CAConfMsgHandler, SetCurrentA5());
  639. //                            if (errCode != noErr)
  640. //                                PutCLine (gLogWindow, kErrorColor, "### TELCAMsgHand fails : %d", errCode);
  641.                     }
  642.                     else {
  643.                         PutCLine (gLogWindow, kErrorColor, "### TELConferencePrep fails : %d", errCode);
  644.                         
  645.                         RemoveFromCAList ((DNWindowPtr) (*caHand1)->refCon, caHand2);
  646.                     }
  647.                 }
  648.             }
  649.             else
  650.                 PutCLine (gLogWindow, kErrorColor, "### TELGetCAFlags fails : %d", errCode);
  651.         }
  652.         else {
  653.             if ((errCode = TELConferenceEstablish ((*caHand1)->relatedCA, caHand1)) == noErr)
  654.                 PutLine (gLogWindow, "TELConferenceEstablish (%08x,%08x)", (*caHand1)->relatedCA, caHand1);
  655.             else
  656.                 PutCLine (gLogWindow, kErrorColor, "### TELConferenceEstablish fails : %d", errCode);
  657.             
  658.             caWindow1->fConfInitiated = false;
  659.             SetCTitle (caWindow1->fConf, "\pConference");
  660.         }
  661.     }
  662. }
  663.  
  664.  
  665. #pragma segment CAWindow
  666. void     HandleConfSplit (CAWindowPtr caWindow)
  667. {
  668.     OSErr        errCode;
  669.     TELCAHandle    caHand = caWindow->fCAHandle;
  670.     
  671.     if (caHand) {
  672.         if ((errCode = TELConferenceSplit (caHand)) == noErr)
  673.             PutLine (gLogWindow, "TELConferenceSplit (%08x)", caHand);
  674.         else 
  675.             PutCLine (gLogWindow, kErrorColor, "### TELConferenceSplit fails : %d", errCode);
  676.     }
  677. }
  678.  
  679.  
  680. #pragma segment CAWindow
  681. void    HandleBlindTransfer (CAWindowPtr caWindow)
  682. {
  683.     TransferAttribHandle    tTransferAttrib = caWindow->fTransferAttrib;
  684.     TELCAHandle                caHand = caWindow->fCAHandle;
  685.     OSErr                    errCode;
  686.  
  687.     if (DisplayTransferDialog (caWindow) == ok) {
  688.         errCode = TELTransferBlind (caHand, (*tTransferAttrib)->destDN, 
  689.                         (*tTransferAttrib)->destName,
  690.                         (*tTransferAttrib)->subAddr);
  691.         if (errCode == noErr) 
  692.             PutLine (gLogWindow, "TELTransferBlind (%08x)", caHand);
  693.         else
  694.             PutCLine (gLogWindow, kErrorColor, "### TELTransferBlind fails : %d", errCode);
  695.     }
  696. }
  697.  
  698.  
  699. #pragma segment CAWindow
  700. void    HandleConsultTransfer (CAWindowPtr caWindow1)
  701. {
  702.     TELCAHandle        caHand1 = caWindow1->fCAHandle, caHand2;
  703.     OSErr            errCode;
  704.     CAWindowPtr        caWindow2;
  705.  
  706.     if (caWindow1->fTransferInitiated == false) {
  707.         if ((caHand2 = SetUpACall ((DNWindowPtr) (*caHand1)->refCon)) != nil) {
  708.             if ((errCode = TELTransferPrep (caHand1, caHand2)) == noErr)  {
  709.                 PutLine (gLogWindow, "TELTransferPrep (%08x,%08x)", caHand1, caHand2);
  710.  
  711.                 caWindow2 = (CAWindowPtr) (*caHand2)->userData;
  712.                 caWindow2->fTransferInitiated = true;
  713.                 SetCTitle (caWindow2->fTransfer, "\pTransfer Est");
  714.             }
  715.             else {
  716.                 PutCLine (gLogWindow, kErrorColor, "### TELTransferPrep fails : %d", errCode);
  717.                 RemoveFromCAList ((DNWindowPtr) (*caHand1)->refCon, caHand2);
  718.             }
  719.         }
  720.     }
  721.     else {
  722.         if ((errCode = TELTransferEstablish ((*caHand1)->relatedCA, caHand1)) == noErr)
  723.             PutLine (gLogWindow, "TELTransferEstablish (%08x,%08x)", (*caHand1)->relatedCA, caHand1);
  724.         else
  725.             PutCLine (gLogWindow, kErrorColor, "### TELTransferEstablish fails : %d", errCode);
  726.         
  727.         caWindow1->fTransferInitiated = false;
  728.         SetCTitle (caWindow1->fTransfer, "\pTransfer");
  729.     }
  730. }
  731.  
  732.  
  733. #pragma segment CAWindow
  734. void     HandleTransfer (CAWindowPtr caWindow)
  735. {
  736. #pragma unused (caWindow)
  737. }
  738.  
  739.  
  740. #pragma segment CAWindow
  741. void     HandlePark (CAWindowPtr caWindow)
  742. {
  743.     OSErr        errCode;
  744.     TELCAHandle    caHand = caWindow->fCAHandle;
  745.     Str255        parkDN;
  746.     StringPtr    parkID = nil;
  747.     long        caFeatureFlags, caOtherFeatures;
  748.     
  749.     if (caHand) {
  750.         if ((errCode = TELGetCAFlags (caHand, &caFeatureFlags, &caOtherFeatures)) == noErr) {
  751.     
  752.             if (caOtherFeatures & parkWithGivenID) {
  753.                 if (DisplayParkCallDialog (parkDN) == ok) {
  754.                     errCode = TELParkCall (caHand, &parkID, parkDN);
  755.                     if (errCode == noErr)
  756.                         PutLine (gLogWindow, "TELParkCall (%08x) parkDN = %s parkID = %s", caHand,
  757.                                 parkDN, parkID);
  758.                     else
  759.                         PutCLine (gLogWindow, kErrorColor, "### TELParkCall fails : %d", errCode);
  760.                     
  761.                     if (parkID != nil)
  762.                         DisposPtr ((Ptr) parkID);
  763.                 }
  764.             }
  765.             else
  766.             {
  767.                 errCode = TELParkCall (caHand, &parkID, "\p");
  768.                 if (errCode == noErr)
  769.                     PutLine (gLogWindow, "TELParkCall (%08x) parkID = %s", caHand, parkID);
  770.                 else
  771.                     PutCLine (gLogWindow, kErrorColor, "### TELParkCall fails : %d", errCode);
  772.                 
  773.                 if (parkID != nil)
  774.                     DisposPtr ((Ptr) parkID);
  775.             }
  776.         }
  777.         else
  778.             PutCLine (gLogWindow, kErrorColor, "### TELGetCAFlags fails : %d", errCode);
  779.     }
  780. }
  781.  
  782.  
  783. #pragma segment CAWindow
  784. void     HandleCallBack (CAWindowPtr caWindow)
  785. {
  786.     OSErr        errCode;
  787.     TELCAHandle    caHand = caWindow->fCAHandle;
  788.     short        cbRef = 0;
  789.     
  790.     if (caHand) {
  791.         if ((errCode = TELCallbackSet (caHand, &cbRef)) == noErr){
  792.             PutLine (gLogWindow, "TELCallbackSet (%08x) -> cbRef = %d", caHand, cbRef);
  793.         }
  794.         else {
  795.             PutCLine (gLogWindow, kErrorColor, "### TELCallbackSet fails : %d", errCode);
  796.         }
  797.     }
  798. }
  799.  
  800.  
  801. #pragma segment CAWindow
  802. void     HandleDial (CAWindowPtr caWindow)
  803. {
  804.     OSErr                errCode;
  805.     TELCAHandle    caHand = caWindow->fCAHandle;
  806.     Str255                digits;
  807.  
  808.     if (caHand) {
  809.         if (DisplayGetDigitsDialog (digits) == ok) {
  810.             if ((errCode = TELDialDigits (caHand, digits)) == noErr){
  811.                 PutLine (gLogWindow, "TELDialDigits (%08x)", caHand);
  812.             }
  813.             else {
  814.                 PutCLine (gLogWindow, kErrorColor, "### TELDialDigits fails : %d", errCode);
  815.             }
  816.         }
  817.     }
  818. }
  819.  
  820.  
  821. #pragma segment CAWindow
  822. void     HandleHold (CAWindowPtr caWindow, short * value)
  823. {
  824.     OSErr        errCode;
  825.     TELCAHandle    caHand = caWindow->fCAHandle;
  826.     
  827.     if (caHand) {
  828.         if (*value) {
  829.             if ((errCode = TELHold (caHand)) == noErr){
  830.                 PutLine (gLogWindow, "TELHold (%08x)", caHand);
  831.                 *value = true;
  832.             }
  833.             else {
  834.                 PutCLine (gLogWindow, kErrorColor, "### TELHold fails : %d", errCode);
  835.                 *value = false;
  836.             }
  837.         }
  838.         else {
  839.             if ((errCode = TELRetrieve (caHand)) == noErr){
  840.                 PutLine (gLogWindow, "TELRetrieve (%08x)", caHand);
  841.                 *value = false;
  842.             }
  843.             else {
  844.                 PutCLine (gLogWindow, kErrorColor, "### TELRetrieve fails : %d", errCode);
  845.                 *value = true;
  846.             }
  847.         }
  848.     }
  849. }
  850.  
  851.  
  852. #pragma segment CAWindow
  853. void    PrepareDeflectDLOGUserItems (DialogPtr theDialog)
  854. {
  855.     short    itemType;
  856.     Handle    item;
  857.     Rect    box;
  858.     CursHandle     watch = GetCursor(watchCursor);
  859.     
  860.     if (watch != nil)
  861.         SetCursor (*watch);
  862.     
  863.     GetDItem (theDialog, kDeflectBox1, &itemType, &item, &box);
  864.     SetDItem (theDialog, kDeflectBox1, itemType, (Handle) gDrawBoxUPP, &box);
  865.     
  866.     GetDItem (theDialog, kDeflectDefault, &itemType, &item, &box);
  867.     SetDItem (theDialog, kDeflectDefault, itemType, (Handle) gDrawDefaultUPP, &box);
  868.     
  869.     if (watch != nil)
  870.         ReleaseResource ((Handle) watch);
  871.     
  872.     SetCursor (&qd.arrow);
  873. }
  874.  
  875.  
  876. #pragma segment CAWindow
  877. short    DisplayDeflectDialog (CAWindowPtr caWindow)
  878. {
  879.     DialogPtr    theDialog;
  880.     short        itemHit;
  881.     short        returnValue;
  882.     DeflectAttribHandle    theDeflectAttrib = caWindow->fDeflectAttrib;
  883.     
  884.     theDialog = GetNewDialog (rDeflectDLOG, nil, (WindowPtr)(-1L));
  885.     if (theDialog == nil) {
  886.         AlertUser ("\pUnable to get a DLOG resource !", ResError());
  887.         return (-1);
  888.     }
  889.     
  890.     PrepareDeflectDLOGUserItems (theDialog);
  891.     PutDeflectAttribToDialog (theDialog, theDeflectAttrib);
  892.  
  893.     ShowWindow (theDialog);
  894.     
  895.     ModalDialog (gStandardFilterUPP, &itemHit);    
  896.         
  897.     HideWindow (theDialog);
  898.     
  899.     switch (itemHit) {
  900.         case ok :
  901.             PutDialogSetupToDeflectAttrib (theDialog, theDeflectAttrib);
  902.             returnValue = ok;
  903.                 
  904.             break;
  905.         
  906.         default :
  907.             returnValue = cancel;
  908.     }
  909.     
  910.     DisposDialog (theDialog);
  911.     
  912.     return (returnValue);
  913. }
  914.  
  915.  
  916. #pragma segment CAWindow
  917. void    PutDeflectAttribToDialog (DialogPtr theDialog, DeflectAttribHandle theDeflectAttrib)
  918. {
  919.     short    itemKind;
  920.     Handle    itemHand;
  921.     Rect    itemRect;
  922.     
  923.     GetDItem (theDialog, kDeflectNumber, &itemKind, &itemHand, &itemRect);
  924.     SetIText (itemHand, (*theDeflectAttrib)->destDN);
  925.     SelIText (theDialog, kDeflectNumber, 0, 32767);
  926.     
  927.     GetDItem (theDialog, kDeflectSubAddr, &itemKind, &itemHand, &itemRect);
  928.     SetIText (itemHand, (*theDeflectAttrib)->subAddr);
  929. }
  930.  
  931.  
  932. #pragma segment CAWindow
  933. void    PutDialogSetupToDeflectAttrib (DialogPtr theDialog, DeflectAttribHandle theDeflectAttrib)
  934. {
  935.     short    itemKind;
  936.     Handle    itemHand;
  937.     Rect    itemRect;
  938.     
  939.     GetDItem (theDialog, kDeflectNumber, &itemKind, &itemHand, &itemRect);
  940.     GetIText (itemHand, (*theDeflectAttrib)->destDN);
  941.     GetDItem (theDialog, kDeflectSubAddr, &itemKind, &itemHand, &itemRect);
  942.     GetIText (itemHand, (*theDeflectAttrib)->subAddr);
  943. }
  944.  
  945.  
  946. #pragma segment CAWindow
  947. void    PrepareTransferDLOGUserItems (DialogPtr theDialog)
  948. {
  949.     short    itemType;
  950.     Handle    item;
  951.     Rect    box;
  952.     CursHandle     watch = GetCursor(watchCursor);
  953.     
  954.     if (watch != nil)
  955.         SetCursor (*watch);
  956.     
  957.     GetDItem (theDialog, kTransferBox1, &itemType, &item, &box);
  958.     SetDItem (theDialog, kTransferBox1, itemType, (Handle) gDrawBoxUPP, &box);
  959.     
  960.     GetDItem (theDialog, kTransferDefault, &itemType, &item, &box);
  961.     SetDItem (theDialog, kTransferDefault, itemType, (Handle) gDrawDefaultUPP, &box);
  962.     
  963.     if (watch != nil)
  964.         ReleaseResource ((Handle) watch);
  965.     
  966.     SetCursor (&qd.arrow);
  967. }
  968.  
  969.  
  970. #pragma segment CAWindow
  971. short    DisplayTransferDialog (CAWindowPtr caWindow)
  972. {
  973.     DialogPtr    theDialog;
  974.     short        itemHit;
  975.     short        returnValue;
  976.     TransferAttribHandle    theTransferAttrib = caWindow->fTransferAttrib;
  977.     
  978.     theDialog = GetNewDialog (rTransferDLOG, nil, (WindowPtr)(-1L));
  979.     if (theDialog == nil) {
  980.         AlertUser ("\pUnable to get a DLOG resource !", ResError());
  981.         return (-1);
  982.     }
  983.     
  984.     PrepareTransferDLOGUserItems (theDialog);
  985.     PutTransferAttribToDialog (theDialog, theTransferAttrib);
  986.  
  987.     ShowWindow (theDialog);
  988.     
  989.     ModalDialog (gStandardFilterUPP, &itemHit);    
  990.         
  991.     HideWindow (theDialog);
  992.     
  993.     switch (itemHit) {
  994.         case ok :
  995.             PutDialogSetupToTransferAttrib (theDialog, theTransferAttrib);
  996.             returnValue = ok;
  997.                 
  998.             break;
  999.         
  1000.         default :
  1001.             returnValue = cancel;
  1002.     }
  1003.     
  1004.     DisposDialog (theDialog);
  1005.     
  1006.     return (returnValue);
  1007. }
  1008.  
  1009.  
  1010. #pragma segment CAWindow
  1011. void    PutTransferAttribToDialog (DialogPtr theDialog, TransferAttribHandle theTransferAttrib)
  1012. {
  1013.     short    itemKind;
  1014.     Handle    itemHand;
  1015.     Rect    itemRect;
  1016.     
  1017.     GetDItem (theDialog, kTransferNumber, &itemKind, &itemHand, &itemRect);
  1018.     SetIText (itemHand, (*theTransferAttrib)->destDN);
  1019.     SelIText (theDialog, kTransferNumber, 0, 32767);
  1020.     
  1021.     GetDItem (theDialog, kTransferName, &itemKind, &itemHand, &itemRect);
  1022.     SetIText (itemHand, (*theTransferAttrib)->destName);
  1023.     
  1024.     GetDItem (theDialog, kTransferSubAddr, &itemKind, &itemHand, &itemRect);
  1025.     SetIText (itemHand, (*theTransferAttrib)->subAddr);
  1026. }
  1027.  
  1028.  
  1029. #pragma segment CAWindow
  1030. void    PutDialogSetupToTransferAttrib (DialogPtr theDialog, TransferAttribHandle theTransferAttrib)
  1031. {
  1032.     short    itemKind;
  1033.     Handle    itemHand;
  1034.     Rect    itemRect;
  1035.     
  1036.     GetDItem (theDialog, kTransferNumber, &itemKind, &itemHand, &itemRect);
  1037.     GetIText (itemHand, (*theTransferAttrib)->destDN);
  1038.     GetDItem (theDialog, kTransferName, &itemKind, &itemHand, &itemRect);
  1039.     GetIText (itemHand, (*theTransferAttrib)->destName);
  1040.     GetDItem (theDialog, kTransferSubAddr, &itemKind, &itemHand, &itemRect);
  1041.     GetIText (itemHand, (*theTransferAttrib)->subAddr);
  1042. }
  1043.  
  1044.  
  1045. #pragma segment CAWindow
  1046. void    PrepareParkCallDLOGUserItems (DialogPtr theDialog)
  1047. {
  1048.     short    itemType;
  1049.     Handle    item;
  1050.     Rect    box;
  1051.     CursHandle     watch = GetCursor(watchCursor);
  1052.     
  1053.     if (watch != nil)
  1054.         SetCursor (*watch);
  1055.     
  1056.     GetDItem (theDialog, kParkCallBox1, &itemType, &item, &box);
  1057.     SetDItem (theDialog, kParkCallBox1, itemType, (Handle) gDrawBoxUPP, &box);
  1058.     
  1059.     GetDItem (theDialog, kParkCallDefault, &itemType, &item, &box);
  1060.     SetDItem (theDialog, kParkCallDefault, itemType, (Handle) gDrawDefaultUPP, &box);
  1061.     
  1062.     if (watch != nil)
  1063.         ReleaseResource ((Handle) watch);
  1064.     
  1065.     SetCursor (&qd.arrow);
  1066. }
  1067.  
  1068.  
  1069. #pragma segment CAWindow
  1070. short    DisplayParkCallDialog (Str255 parkDN)
  1071. {
  1072.     DialogPtr    theDialog;
  1073.     short        itemHit;
  1074.     short        returnValue;
  1075.     short        itemKind;
  1076.     Handle        itemHand;
  1077.     Rect        itemRect;
  1078.     
  1079.     theDialog = GetNewDialog (rParkCallDLOG, nil, (WindowPtr)(-1L));
  1080.     if (theDialog == nil) {
  1081.         AlertUser ("\pUnable to get a DLOG resource !", ResError());
  1082.         return (-1);
  1083.     }
  1084.     
  1085.     PrepareParkCallDLOGUserItems (theDialog);
  1086.     
  1087.     ShowWindow (theDialog);
  1088.     
  1089.     ModalDialog (gStandardFilterUPP, &itemHit);    
  1090.         
  1091.     HideWindow (theDialog);
  1092.     
  1093.     switch (itemHit) {
  1094.         case ok :
  1095.             GetDItem (theDialog, kParkCallNumber, &itemKind, &itemHand, &itemRect);
  1096.             GetIText (itemHand, parkDN);
  1097.             returnValue = ok;
  1098.             break;
  1099.         
  1100.         default :
  1101.             returnValue = cancel;
  1102.     }
  1103.     
  1104.     DisposDialog (theDialog);
  1105.     
  1106.     return (returnValue);
  1107. }
  1108.  
  1109.  
  1110. #pragma segment CAWindow
  1111. void    PrepareGetDigitsDLOGUserItems (DialogPtr theDialog)
  1112. {
  1113.     short    itemType;
  1114.     Handle    item;
  1115.     Rect    box;
  1116.     CursHandle     watch = GetCursor(watchCursor);
  1117.     
  1118.     if (watch != nil)
  1119.         SetCursor (*watch);
  1120.     
  1121.     GetDItem (theDialog, kGetDigitsBox1, &itemType, &item, &box);
  1122.     SetDItem (theDialog, kGetDigitsBox1, itemType, (Handle) gDrawBoxUPP, &box);
  1123.     
  1124.     GetDItem (theDialog, kGetDigitsDefault, &itemType, &item, &box);
  1125.     SetDItem (theDialog, kGetDigitsDefault, itemType, (Handle) gDrawDefaultUPP, &box);
  1126.     
  1127.     if (watch != nil)
  1128.         ReleaseResource ((Handle) watch);
  1129.     
  1130.     SetCursor (&qd.arrow);
  1131. }
  1132.  
  1133.  
  1134. #pragma segment CAWindow
  1135. short    DisplayGetDigitsDialog (Str255 digits)
  1136. {
  1137.     DialogPtr    theDialog;
  1138.     short        itemHit;
  1139.     short        returnValue;
  1140.     short        itemKind;
  1141.     Handle        itemHand;
  1142.     Rect        itemRect;
  1143.     
  1144.     theDialog = GetNewDialog (rGetDigitsDLOG, nil, (WindowPtr)(-1L));
  1145.     if (theDialog == nil) {
  1146.         AlertUser ("\pUnable to get a DLOG resource !", ResError());
  1147.         return (-1);
  1148.     }
  1149.     
  1150.     PrepareGetDigitsDLOGUserItems (theDialog);
  1151.     
  1152.     ShowWindow (theDialog);
  1153.     
  1154.     ModalDialog (gStandardFilterUPP, &itemHit);    
  1155.         
  1156.     HideWindow (theDialog);
  1157.     
  1158.     switch (itemHit) {
  1159.         case ok :
  1160.             GetDItem (theDialog, kGetDigitsNumber, &itemKind, &itemHand, &itemRect);
  1161.             GetIText (itemHand, digits);
  1162.             returnValue = ok;
  1163.             break;
  1164.         
  1165.         default :
  1166.             returnValue = cancel;
  1167.     }
  1168.     
  1169.     DisposDialog (theDialog);
  1170.     
  1171.     return (returnValue);
  1172. }
  1173.  
  1174.  
  1175. #pragma segment CAWindow
  1176. void    PrepareGetUserUserInfoDLOGUserItems (DialogPtr theDialog)
  1177. {
  1178.     short    itemType;
  1179.     Handle    item;
  1180.     Rect    box;
  1181.     CursHandle     watch = GetCursor(watchCursor);
  1182.     
  1183.     if (watch != nil)
  1184.         SetCursor (*watch);
  1185.     
  1186.     GetDItem (theDialog, kGetUserUserInfoBox1, &itemType, &item, &box);
  1187.     SetDItem (theDialog, kGetUserUserInfoBox1, itemType, (Handle) gDrawBoxUPP, &box);
  1188.     
  1189.     GetDItem (theDialog, kGetUserUserInfoDefault, &itemType, &item, &box);
  1190.     SetDItem (theDialog, kGetUserUserInfoDefault, itemType, (Handle) gDrawDefaultUPP, &box);
  1191.     
  1192.     if (watch != nil)
  1193.         ReleaseResource ((Handle) watch);
  1194.     
  1195.     SetCursor (&qd.arrow);
  1196. }
  1197.  
  1198.  
  1199. #pragma segment CAWindow
  1200. short    GetUserUserInfo (Str255 userUserInfo)
  1201. {
  1202.     DialogPtr    theDialog;
  1203.     short        itemHit;
  1204.     short        returnValue;
  1205.     short        itemKind;
  1206.     Handle        itemHand;
  1207.     Rect        itemRect;
  1208.     
  1209.     theDialog = GetNewDialog (rGetUserUserInfoDLOG, nil, (WindowPtr)(-1L));
  1210.     if (theDialog == nil) {
  1211.         AlertUser ("\pUnable to get a DLOG resource !", ResError());
  1212.         return (-1);
  1213.     }
  1214.     
  1215.     PrepareGetUserUserInfoDLOGUserItems (theDialog);
  1216.     
  1217.     ShowWindow (theDialog);
  1218.     
  1219.     ModalDialog (gStandardFilterUPP, &itemHit);    
  1220.         
  1221.     HideWindow (theDialog);
  1222.     
  1223.     switch (itemHit) {
  1224.         case ok :
  1225.             GetDItem (theDialog, kGetUserUserInfoNumber, &itemKind, &itemHand, &itemRect);
  1226.             GetIText (itemHand, userUserInfo);
  1227.             returnValue = ok;
  1228.             break;
  1229.         
  1230.         default :
  1231.             returnValue = cancel;
  1232.     }
  1233.     
  1234.     DisposDialog (theDialog);
  1235.     
  1236.     return (returnValue);
  1237. }
  1238.  
  1239.  
  1240. #pragma segment CAWindow
  1241. void    PrepareGetReasonDLOGUserItems (DialogPtr theDialog)
  1242. {
  1243.     short    itemType;
  1244.     Handle    item;
  1245.     Rect    box;
  1246.     CursHandle     watch = GetCursor(watchCursor);
  1247.     
  1248.     if (watch != nil)
  1249.         SetCursor (*watch);
  1250.     
  1251.     GetDItem (theDialog, kGetReasonBox1, &itemType, &item, &box);
  1252.     SetDItem (theDialog, kGetReasonBox1, itemType, (Handle) gDrawBoxUPP, &box);
  1253.     
  1254.     GetDItem (theDialog, kGetReasonDefault, &itemType, &item, &box);
  1255.     SetDItem (theDialog, kGetReasonDefault, itemType, (Handle) gDrawDefaultUPP, &box);
  1256.     
  1257.     if (watch != nil)
  1258.         ReleaseResource ((Handle) watch);
  1259.     
  1260.     SetCursor (&qd.arrow);
  1261. }
  1262.  
  1263.  
  1264. #pragma segment CAWindow
  1265. short    GetReason (short * reason)
  1266. {
  1267.     DialogPtr    theDialog;
  1268.     short        itemHit;
  1269.     short        returnValue;
  1270.     short        itemKind;
  1271.     Handle        itemHand;
  1272.     Rect        itemRect;
  1273.     Str255        tStr;
  1274.     long        tlong;
  1275.     
  1276.     theDialog = GetNewDialog (rGetReasonDLOG, nil, (WindowPtr)(-1L));
  1277.     if (theDialog == nil) {
  1278.         AlertUser ("\pUnable to get a DLOG resource !", ResError());
  1279.         return (-1);
  1280.     }
  1281.     
  1282.     PrepareGetReasonDLOGUserItems (theDialog);
  1283.     
  1284.     ShowWindow (theDialog);
  1285.     
  1286.     ModalDialog (gStandardFilterUPP, &itemHit);    
  1287.         
  1288.     HideWindow (theDialog);
  1289.     
  1290.     switch (itemHit) {
  1291.         case ok :
  1292.             GetDItem (theDialog, kGetReasonNumber, &itemKind, &itemHand, &itemRect);
  1293.             GetIText (itemHand, tStr);
  1294.             StringToNum (tStr, &tlong);
  1295.             *reason = tlong;
  1296.             returnValue = ok;
  1297.             break;
  1298.         
  1299.         default :
  1300.             returnValue = cancel;
  1301.     }
  1302.     
  1303.     DisposDialog (theDialog);
  1304.     
  1305.     return (returnValue);
  1306. }
  1307.  
  1308.  
  1309. #pragma segment CAWindow
  1310. void    HandleTransferWithCA (CAWindowPtr caWindow)
  1311. {
  1312.     TELCAHandle        caHand1 = caWindow->fCAHandle, caHand2;
  1313.     OSErr            errCode;
  1314.     
  1315.     if (! caWindow->fTransferInitiated) {
  1316.         switch (DisplayGetCAListDialog (&caHand2, caWindow)) {
  1317.             case ok :
  1318.                 if ((errCode = TELTransferPrep (caHand1, caHand2)) == noErr)  {
  1319.                     PutLine (gLogWindow, "TELTransferPrep (%08x,%08x)", caHand1, caHand2);
  1320.                     
  1321.                     if ((errCode = TELTransferEstablish (caHand1, caHand2)) == noErr)
  1322.                         PutLine (gLogWindow, "TELTransferEstablish (%08x,%08x)", caHand1, caHand2);
  1323.                     else
  1324.                         PutCLine (gLogWindow, kErrorColor, "### TELTransferEstablish fails : %d", errCode);
  1325.                 }
  1326.                 else
  1327.                     PutCLine (gLogWindow, kErrorColor, "### TELTransferPrep fails : %d", errCode);
  1328.                 break;
  1329.             
  1330.             case kGetCAListNewCA :
  1331.                 HandleConsultTransfer (caWindow);
  1332.                 break;
  1333.         }
  1334.     }
  1335.     else
  1336.         HandleConsultTransfer (caWindow);
  1337. }
  1338.  
  1339.  
  1340. #pragma segment CAWindow
  1341. void    HandleConferenceWithCA (CAWindowPtr caWindow)
  1342. {
  1343.     TELCAHandle        caHand1 = caWindow->fCAHandle, caHand2;
  1344.     OSErr            errCode;
  1345.     
  1346.     if (! caWindow->fConfInitiated) {
  1347.         switch (DisplayGetCAListDialog (&caHand2, caWindow)) {
  1348.             case ok :
  1349.                 if ((errCode = TELConferencePrep (caHand1, caHand2, (*caHand1)->conferenceLimit)) == noErr)  {
  1350.                     PutLine (gLogWindow, "TELConferencePrep (%08x,%08x)", caHand1, caHand2);
  1351.                     
  1352.                     if ((errCode = TELConferenceEstablish (caHand1, caHand2)) == noErr)
  1353.                         PutLine (gLogWindow, "TELConferenceEstablish (%08x,%08x)", caHand1, caHand2);
  1354.                     else
  1355.                         PutCLine (gLogWindow, kErrorColor, "### TELConferenceEstablish fails : %d", errCode);
  1356.                 }
  1357.                 else
  1358.                     PutCLine (gLogWindow, kErrorColor, "### TELConferencePrep fails : %d", errCode);
  1359.                 break;
  1360.             
  1361.             case kGetCAListNewCA :
  1362.                 HandleConf (caWindow);
  1363.                 break;
  1364.         }
  1365.     }
  1366.     else
  1367.         HandleConf (caWindow);
  1368. }
  1369.  
  1370.  
  1371. #pragma segment CAWindow
  1372. void    PrepareGetCAListDLOGUserItems (DialogPtr theDialog, CAWindowPtr caWindow)
  1373. {
  1374.     short        itemType;
  1375.     Handle        item;
  1376.     Rect        box;
  1377.     CursHandle     watch = GetCursor(watchCursor);
  1378.     
  1379.     if (watch != nil)
  1380.         SetCursor (*watch);
  1381.     
  1382.     GetDItem (theDialog, kGetCAListBox1, &itemType, &item, &box);
  1383.     SetDItem (theDialog, kGetCAListBox1, itemType, (Handle) gDrawBoxUPP, &box);
  1384.     
  1385.     GetDItem (theDialog, kGetCAListDefault, &itemType, &item, &box);
  1386.     SetDItem (theDialog, kGetCAListDefault, itemType, (Handle) gDrawDefaultUPP, &box);
  1387.     
  1388.     BuildCAListMenu (GetPopupMHandle (theDialog, kGetCAListPopup), caWindow);
  1389.     SetPopupValue (theDialog, kGetCAListPopup, 1);
  1390.  
  1391.     if (watch != nil)
  1392.         ReleaseResource ((Handle) watch);
  1393.     
  1394.     SetCursor (&qd.arrow);
  1395. }
  1396.  
  1397.  
  1398. #pragma segment CAWindow
  1399. short    DisplayGetCAListDialog (TELCAHandle *caHand, CAWindowPtr caWindow)
  1400. {
  1401.     DialogPtr    theDialog;
  1402.     short        itemHit;
  1403.     short        returnValue;
  1404.     
  1405.     theDialog = GetNewDialog (rGetCAListDLOG, nil, (WindowPtr)(-1L));
  1406.     if (theDialog == nil) {
  1407.         AlertUser ("\pUnable to get a DLOG resource !", ResError());
  1408.         return (-1);
  1409.     }
  1410.     
  1411.     PrepareGetCAListDLOGUserItems (theDialog, caWindow);
  1412.     
  1413.     ShowWindow (theDialog);
  1414.     
  1415.     ModalDialog (gStandardFilterUPP, &itemHit);    
  1416.         
  1417.     HideWindow (theDialog);
  1418.     
  1419.     switch (itemHit) {
  1420.         case ok :
  1421.             *caHand = GetNthCA (GetPopupValue (theDialog, kGetCAListPopup), GetDNWindow (caWindow->fCAHandle));
  1422.             
  1423.             if (*caHand)
  1424.                 returnValue = ok;
  1425.             else
  1426.                 returnValue = cancel;
  1427.             break;
  1428.         
  1429.         default :
  1430.             returnValue = itemHit;
  1431.     }
  1432.     
  1433.     DisposDialog (theDialog);
  1434.     
  1435.     return (returnValue);
  1436. }
  1437.  
  1438.  
  1439. #pragma segment CAWindow
  1440. void    BuildCAListMenu (MenuHandle theMenu, CAWindowPtr caWindow)
  1441. {
  1442.     DNWindowPtr     dnWindow;
  1443.     ListHandle        theList;
  1444.     Str255            caString;
  1445.     TELCAHandle        caHand = caWindow->fCAHandle;
  1446.     short            length, item = 1;
  1447.     Cell            tCell;
  1448.     
  1449.     if (caHand)
  1450.     {
  1451.         dnWindow = GetDNWindow (caHand);
  1452.         theList = dnWindow->fCAList;
  1453.         caWindow = dnWindow->fCAWindowList;
  1454.         
  1455.         SetPt (&tCell, 0, 0);
  1456.         while (caWindow) {
  1457.             length = 0xFF;
  1458.             LGetCell (caString+1, &length, tCell, theList);
  1459.             caString[0] = length;
  1460.  
  1461.             AppendMenu (theMenu, "\pX");
  1462.             SetItem (theMenu, item, caString); 
  1463.             
  1464.             if (caHand == caWindow->fCAHandle)
  1465.                 DisableItem (theMenu, item);
  1466.             
  1467.             caWindow = caWindow->next;
  1468.             ++item; ++tCell.v;
  1469.         }
  1470.     }
  1471. }
  1472.  
  1473.  
  1474.